﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Documents;
using System.Windows;
using HTMLConverter;
using System.IO;

namespace MyRssReader
{
    class FlowDescription:Section
    {
        public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register(
            "Description", typeof(String), typeof(FlowDescription),
            new PropertyMetadata(new PropertyChangedCallback(FlowDescription.onDescriptionChanged))
            );
        private static void onDescriptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            using (MemoryStream stream = new MemoryStream(new UTF8Encoding().GetBytes(e.NewValue.ToString())))
            {
                TextRange text = new TextRange(((Section)d).ContentEnd, ((Section)d).ContentEnd);
                text.Load(stream, DataFormats.Xaml);                
            }
        }
        public String Description
        {
            set
            {
                SetValue(DescriptionProperty, value);
            }
            get
            {
                return (String)GetValue(DescriptionProperty);
            }
        }
    }
}
